//
//  GameZanTableViewCell.m
//  GOGOTravel
//
//  Created by dllo on 16/3/5.
//  Copyright © 2016年 果果. All rights reserved.
//

#import "GameZanTableViewCell.h"
#import "GameZanCollectionViewCell.h"

@interface GameZanTableViewCell ()<UICollectionViewDataSource, UICollectionViewDelegate>

@property (nonatomic, retain) BaseCollectionView *collection;



@end


@implementation GameZanTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createCollection];
    }
    return self;
}

- (void)createCollection{
    
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    
    layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    layout.itemSize = CGSizeMake(60,60);
    layout.minimumInteritemSpacing = 10;
    layout.minimumLineSpacing = 10;
    layout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);
    
    self.collection = [[BaseCollectionView alloc] initWithFrame:CGRectMake(5, 5, [UIScreen mainScreen].bounds.size.width, 60) collectionViewLayout:layout];
    
    _collection.delegate = self;
    _collection.dataSource = self;
    
    _collection.showsHorizontalScrollIndicator = NO;
    [self addSubview:_collection];
    
    [_collection release];
    
    [_collection registerClass:[GameZanCollectionViewCell class] forCellWithReuseIdentifier:@"GameZanCollectionViewCell"];
    
    
    
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return _arr.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    GameZanCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"GameZanCollectionViewCell" forIndexPath:indexPath];
    cell.backgroundColor = UIColorFromRGB(0xF0F0F0);
    GameXangQing *model = _arr[indexPath.row];
    cell.model = model;
    
    return cell;
}



- (void)dealloc{
    [_arr release];
    [_collection release];
    [super dealloc];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
